package com.kzc.util;

import com.kzc.base.ResponseWrapper;
import com.kzc.contst.Constants;

import java.util.List;

public class ResponseDataUtils {

    public  static<T> ResponseWrapper<T> responseSuccess(int status,String message,T data, List<T> list){
        ResponseWrapper<T> responseWrapper = new ResponseWrapper<>();
        responseWrapper.setStatus(status);
        if(status == Constants.RESPONSE_SUCCESS_STATUS){
            responseWrapper.setMessage(Constants.RESPONSE_SUCCESS_STR);
        }else{
            if(message.isEmpty()){
                responseWrapper.setMessage(Constants.RESPONSE_SUCCESS_STR);
            }else{
                responseWrapper.setMessage(message);
            }
        }

        if(data!=null){
            responseWrapper.setData(data);
        }

        if(list!=null){
            responseWrapper.setList(list);
        }

        return responseWrapper;
    }



}
